#    SUSAN® - Sole of Unix Save ANything
#
#   Copyright (C) 2017-2020 Hechzh Property
#
#   This program is Free Software; you can redistribute it and/or
#   modify it under the terms of version three of the GNU Affero General Public
#   License as published by the Free Software Foundation and included
#   in the file LICENSE.
#
#   This program is distributed in the hope that it will be useful, but
#   WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#   Affero General Public License for more details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
#   02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")

list(APPEND CMAKE_INSTALL_RPATH ${backenddir})

if(${HAVE_CEPHFS})
  add_library(susansd-cephfs MODULE cephfs_device.cc)
  install(TARGETS susansd-cephfs DESTINATION ${backenddir})
  target_link_libraries(susansd-cephfs ${CEPHFS_LIBRARIES})
endif()

if(${HAVE_CEPH_RADOS})
  add_library(susansd-rados MODULE rados_device.cc)
  install(TARGETS susansd-rados DESTINATION ${backenddir})
  target_link_libraries(susansd-rados ${RADOS_LIBRARIES})
endif()

if(${HAVE_GLUSTERFS})
  add_library(susansd-gfapi MODULE gfapi_device.cc)
  install(TARGETS susansd-gfapi DESTINATION ${backenddir})
  target_include_directories(susansd-gfapi PUBLIC ${GFAPI_INCLUDE_DIRS})
  target_link_libraries(susansd-gfapi ${GFAPI_LIBRARIES})
endif()

if(TARGET droplet)
  add_library(susansd-chunked SHARED ordered_cbuf.cc chunked_device.cc)
  target_link_libraries(susansd-chunked droplet)
  install(TARGETS susansd-chunked DESTINATION ${backenddir})

  add_library(susansd-droplet MODULE droplet_device.cc)
  target_link_libraries(susansd-droplet susansd-chunked droplet)
  install(TARGETS susansd-droplet DESTINATION ${backenddir})
endif()

add_library(susansd-fifo MODULE unix_fifo_device.cc)
install(TARGETS susansd-fifo DESTINATION ${backenddir})
if(HAVE_DARWIN_OS)
  target_link_libraries(susansd-fifo susan susansd)
endif()

add_library(susansd-gentape SHARED generic_tape_device.cc)
install(TARGETS susansd-gentape DESTINATION ${backenddir})
if(HAVE_DARWIN_OS)
  target_link_libraries(susansd-gentape susan susansd)
endif()

add_library(susansd-tape MODULE unix_tape_device.cc)
install(TARGETS susansd-tape DESTINATION ${backenddir})

target_link_libraries(susansd-tape susansd-gentape)
